#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import bs4
import requests


def getlevels(href):
    # id -> level 集合
    URL = "http://tieba.baidu.com%s" % href

    response = requests.get(URL)
    soup = bs4.BeautifulSoup(response.text, "lxml")
    return set(t.text \
        for t in soup.find_all('div', {'class': 'd_badge_title'}))

href = "/p/5813806865"
print(getlevels(href))

# 贴吧名称 -> 所有帖子的id

